package edu.uta.cfl.GUI;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;

public class TableDecorator {

	private JTable jtable;

	public TableDecorator(JTable table) {
		this.jtable = table;
		}

	public void updateTableUI()
	{
		jtable.setDefaultRenderer(Object.class,
				new TableCellRenderer() {
					private DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer();

					@Override
					public Component getTableCellRendererComponent(
							JTable table, Object value,
							boolean isSelected,
							boolean hasFocus, int row,
							int column) {
						Component c = DEFAULT_RENDERER
								.getTableCellRendererComponent(
										table, value,
										isSelected,
										hasFocus, row,
										column);
						if (row % 2 == 0) {
							c.setBackground(Color.WHITE);
						} else {
							c.setBackground(Color.LIGHT_GRAY);
						}
						return c;
					}

				});

	}
}
